<?php
# 简单实现阿里云盘的签到
$tokens = [
    '13719205474'=>'cc76bf79477049d491cb0fd1888673b7',
//    '19223200487'=>'964ea2cd26b04fbd9918e013e19435b0',//欧美,没绑定支付宝gzx****752
//    '19034198104'=>'4af98bd84f2247098228e5d9f3369a4e',//国产
    // '19539241908'=>'',
    // '15017569137'=>'',
    // '15920506852'=>'',
    // '13265141630'=>'',
];

//sleep(rand(0,6));

foreach ($tokens as $k=>$token) {
    echo $k.PHP_EOL;
    $token = trim($token);
    if (!$token) continue;
    $body = [
        'grant_type' => 'refresh_token',
        'refresh_token' => $token,
    ];
    $headerArray = ["Content-type:application/json;charset='utf-8'"];
    $authUrl = 'https://auth.aliyundrive.com/v2/account/token';
    $out = posturl($authUrl, $body, $headerArray);
    sleep(1);
    $signURL = "https://member.aliyundrive.com/v1/activity/sign_in_list";
    $access_token = $out['access_token'];
    $headerArray[] = "Authorization: Bearer " . $access_token;
    $out = posturl($signURL, $body, $headerArray);
    if ($out['success']) {
        echo '签到成功'.PHP_EOL;
    }
    echo str_repeat('=',10).PHP_EOL;
    sleep(1);
}

function posturl($url, $data, $header)
{
    $data = json_encode($data);
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($curl);
    curl_close($curl);
    return json_decode($output, true);
}





